from pymongo import MongoClient as MC
import json


class Con_DB(object):
    def __init__(self):
        client = MC('localhost', 27017)
        db = client.homework
        self.mov = db.move

    def insert_data(self,ls):
        user_a = {
            'name': ls[0],
            'types': ls[1],
            't':ls[2]
        }
        self.mov.insert_one(user_a)


if __name__ == '__main__':
    connect = Con_DB()
    with open('./in_theaters.json','r') as f:
        load = json.load(f)
        resluts = load['subjects']
        for items in resluts:
            ls=[]
            ls.append(items['title'])
            ls.append(items['genres'])
            ls.append(items['mainland_pubdate'])
            connect.insert_data(ls)